package com.dman.multi.proxy;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.URL;
import java.nio.channels.SocketChannel;

public class NoProxyHandler implements ProxyHandler {
	@Override
	public boolean connect(SocketChannel sockChannel, ProxyAdaptor proxyAuth,
			URL url) throws IOException {
		int port = url.getPort();
		if(port < 0)
			port = url.getDefaultPort();
		String host = url.getHost();
		InetSocketAddress isa = new InetSocketAddress(host, port);
		return sockChannel.connect(isa);
	}
	
	@Override
	public String identifyProtocol(URL url, ProxyAdaptor proxyAuth)
			throws IOException {
		return url.getProtocol();
	}
}
